package org.wanho.shop.mapper;

import org.wanho.shop.entity.Item;
import org.wanho.shop.entity.Product;
import org.wanho.util.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Author：汤小洋
 * Date：2023-04-27 15:58
 * Description：<描述>
 */
public class ItemMapper implements RowMapper<Item> {
    @Override
    public Item mapRow(ResultSet rs) throws SQLException {
        Item item = new Item();
        item.setId(rs.getInt("id"));
        item.setNum(rs.getInt("num"));
        item.setPrice(rs.getDouble("price"));
        Product product = new Product();
        product.setName(rs.getString("name"));
        item.setProduct(product);
        return item;
    }
}
